﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Øving3Blackjack
{
    class Deck : List<Card>
    {
        private Random random = new Random();
        private int decks;

        public Deck(int decks)
        {
            this.decks = decks;
            this.shuffleDeck();
            
        }

        public void addCard(Card card)
        {
            this.Add(card);
        }

        public Card getRemoveCard()
        {
            int listNumber = random.Next(1, this.Count) -1;
            Card dealtCard = this.ElementAt(listNumber);
            this.RemoveAt(listNumber);
            return dealtCard;
        }
        public void changeDecks(int decks)
        {
            this.decks = decks;
        }
        public Boolean hasFewCards()
        {
            return this.Count < 33;
        }

        public void shuffleDeck()
        {
            try
            {
                this.RemoveRange(0, this.Count - 1);
            }
            catch (ArgumentOutOfRangeException)
            {

            }
            for (int counter = 0; counter < decks; counter++)
            {
                this.Add(new Card(1, Ranks.DIAMONDS, 11, true, "cards/d/1.gif"));
                this.Add(new Card(2, Ranks.DIAMONDS, 2, false, "cards/d/2.gif"));
                this.Add(new Card(3, Ranks.DIAMONDS, 3, false, "cards/d/3.gif"));
                this.Add(new Card(4, Ranks.DIAMONDS, 4, false, "cards/d/4.gif"));
                this.Add(new Card(5, Ranks.DIAMONDS, 5, false, "cards/d/5.gif"));
                this.Add(new Card(6, Ranks.DIAMONDS, 6, false, "cards/d/6.gif"));
                this.Add(new Card(7, Ranks.DIAMONDS, 7, false, "cards/d/7.gif"));
                this.Add(new Card(8, Ranks.DIAMONDS, 8, false, "cards/d/8.gif"));
                this.Add(new Card(9, Ranks.DIAMONDS, 9, false, "cards/d/9.gif"));
                this.Add(new Card(10, Ranks.DIAMONDS, 10, false, "cards/d/10.gif"));
                this.Add(new Card(11, Ranks.DIAMONDS, 10, false, "cards/d/11.gif"));
                this.Add(new Card(12, Ranks.DIAMONDS, 10, false, "cards/d/12.gif"));
                this.Add(new Card(13, Ranks.DIAMONDS, 10, false, "cards/d/13.gif"));
                this.Add(new Card(1, Ranks.CLUBS, 11, true, "cards/c/1.gif"));
                this.Add(new Card(2, Ranks.CLUBS, 2, false, "cards/c/2.gif"));
                this.Add(new Card(3, Ranks.CLUBS, 3, false, "cards/c/3.gif"));
                this.Add(new Card(4, Ranks.CLUBS, 4, false, "cards/c/4.gif"));
                this.Add(new Card(5, Ranks.CLUBS, 5, false, "cards/c/5.gif"));
                this.Add(new Card(6, Ranks.CLUBS, 6, false, "cards/c/6.gif"));
                this.Add(new Card(7, Ranks.CLUBS, 7, false, "cards/c/7.gif"));
                this.Add(new Card(8, Ranks.CLUBS, 8, false, "cards/c/8.gif"));
                this.Add(new Card(9, Ranks.CLUBS, 9, false, "cards/c/9.gif"));
                this.Add(new Card(10, Ranks.CLUBS, 10, false, "cards/c/10.gif"));
                this.Add(new Card(11, Ranks.CLUBS, 10, false, "cards/c/11.gif"));
                this.Add(new Card(12, Ranks.CLUBS, 10, false, "cards/c/12.gif"));
                this.Add(new Card(13, Ranks.CLUBS, 10, false, "cards/c/13.gif"));
                this.Add(new Card(1, Ranks.HEARTS, 11, true, "cards/h/1.gif"));
                this.Add(new Card(2, Ranks.HEARTS, 2, false, "cards/h/2.gif"));
                this.Add(new Card(3, Ranks.HEARTS, 3, false, "cards/h/3.gif"));
                this.Add(new Card(4, Ranks.HEARTS, 4, false, "cards/h/4.gif"));
                this.Add(new Card(5, Ranks.HEARTS, 5, false, "cards/h/5.gif"));
                this.Add(new Card(6, Ranks.HEARTS, 6, false, "cards/h/6.gif"));
                this.Add(new Card(7, Ranks.HEARTS, 7, false, "cards/h/7.gif"));
                this.Add(new Card(8, Ranks.HEARTS, 8, false, "cards/h/8.gif"));
                this.Add(new Card(9, Ranks.HEARTS, 9, false, "cards/h/9.gif"));
                this.Add(new Card(10, Ranks.HEARTS, 10, false, "cards/h/10.gif"));
                this.Add(new Card(11, Ranks.HEARTS, 10, false, "cards/h/11.gif"));
                this.Add(new Card(12, Ranks.HEARTS, 10, false, "cards/h/12.gif"));
                this.Add(new Card(13, Ranks.HEARTS, 10, false, "cards/h/13.gif"));
                this.Add(new Card(1, Ranks.SPADES, 11, true, "cards/s/1.gif"));
                this.Add(new Card(2, Ranks.SPADES, 2, false, "cards/s/2.gif"));
                this.Add(new Card(3, Ranks.SPADES, 3, false, "cards/s/3.gif"));
                this.Add(new Card(4, Ranks.SPADES, 4, false, "cards/s/4.gif"));
                this.Add(new Card(5, Ranks.SPADES, 5, false, "cards/s/5.gif"));
                this.Add(new Card(6, Ranks.SPADES, 6, false, "cards/s/6.gif"));
                this.Add(new Card(7, Ranks.SPADES, 7, false, "cards/s/7.gif"));
                this.Add(new Card(8, Ranks.SPADES, 8, false, "cards/s/8.gif"));
                this.Add(new Card(9, Ranks.SPADES, 9, false, "cards/s/9.gif"));
                this.Add(new Card(10, Ranks.SPADES, 10, false, "cards/s/10.gif"));
                this.Add(new Card(11, Ranks.SPADES, 10, false, "cards/s/11.gif"));
                this.Add(new Card(12, Ranks.SPADES, 10, false, "cards/s/12.gif"));
                this.Add(new Card(13, Ranks.SPADES, 10, false, "cards/s/13.gif"));
            }
        }
        
    }
}
